<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
    <title>悦章科技机构平台</title>
    <script src="/Public/static/jquery-2.0.3.min.js"></script>
    <script src="/Public/static/layer/layer.js"></script>
    <!--内容样式-->
    <link rel="stylesheet" href="__PUBLIC__/Home/css/style.css" />
</head>
<body>

<div class="main">
    <!--  头部  -->
    <include file="menu" />

    <!--  右侧内容  -->
    <div class="content">
        <div class= "ct-title">
            <div class="ctt-bt">新增班级</div>
            <div class="divclear"></div>
        </div>

        <div class="ct-xz">
            <form action="{:U('Home/Educational/saveClass')}" method="post" class="form-horizontal">
                <input type="hidden" name="id" value="{$info.id}"/>
                <div class="ctx-box">
                    <div class="ctxb-l">班级名称：</div>
                    <div class="ctxb-r">
                        <input type="text" placeholder="请输入班级名称" class="ctxbr-wb" name="name" value="{$info.name}">
                    </div>
                    <div class="divclear"></div>
                </div>
                <div class="ctx-box">
                    <div class="ctxb-l">一级分类：</div>
                    <div class="ctxb-r">
                        <select class="ctxbr-xl" name="one_class_id">
                            <option value="">请选择</option>
                            <volist name="parent" id="vo">
                                <option value="{$vo.id}" <if condition="$info['one_class_id'] eq $vo['id']">selected</if>>{$vo.name}</option>
                            </volist>
                        </select>
                    </div>
                    <div class="divclear"></div>
                </div>
                <div class="ctx-box">
                    <div class="ctxb-l">二级分类：</div>
                    <div class="ctxb-r">
                        <select class="ctxbr-xl" name="two_class_id">
                            <option value="">请选择</option>
                            <volist name="child" id="vo">
                                <option value="{$vo.id}" <if condition="$info['two_class_id'] eq $vo['id']">selected</if>>{$vo.name}</option>
                            </volist>
                        </select>
                    </div>
                    <div class="divclear"></div>
                </div>
                <div class="ctx-box">
                    <div class="ctxb-l">班级状态：</div>
                    <div class="ctxb-r">
                        <select class="ctxbr-xl" name="status">
                            <option value="">请选择</option>
                            <option value="1" <if condition="$info['status'] eq 1">selected</if>>应届</option>
                            <option value="2" <if condition="$info['status'] eq 2">selected</if>>往届</option>
                        </select>
                    </div>
                    <div class="divclear"></div>
                </div>
                <div class="ctx-box">
                    <div class="ctxb-l">开班时间：</div>
                    <div class="ctxb-r">
                        <input type="date" class="ctxbr-wb" name="start_time" value="{$info['start_time']}">
                    </div>
                    <div class="divclear"></div>
                </div>
                <div class="ctx-box">
                    <div class="ctxb-l">结束时间：</div>
                    <div class="ctxb-r">
                        <input type="date" class="ctxbr-wb" name="end_time" value="{$info['end_time']}">
                    </div>
                    <div class="divclear"></div>
                </div>
                <div class="divclear"></div>
                <button class="ctx-btn">确认</button>
            </form>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    $("select[name='one_class_id']").change(function(){
        var cc_id = $(this).val();
        var url = "{:U('Home/Educational/getTwoClass')}";
        $.ajax({
            type: "POST", //类型get，post
            url: url, //链接地址
            data:{"cc_id":cc_id},//参数，一般post用
            success: function(data){
                var dataObj = JSON.parse(data);
                $("select[name='two_class_id']").empty();
                $("select[name='two_class_id']").append("<option value=''>请选择</option>");
                //成功后函数
                if(dataObj.result == 1){
                    for(var i=0;i<dataObj.data.length;i++){
                        $("select[name='two_class_id']").append("<option value='"+dataObj.data[i]['id']+"'>"+dataObj.data[i]['name']+"</option>");
                    }
                }
            },
            error:function(){
                //失败时函数
                layer.msg("失败");
            }
        })
    })
</script>
</html>
